package com.kkb.kkbadmin.controller;

import com.kkb.kkbadmin.service.FameService;
import com.kkb.kkbcommon.api.CommonResult;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @ClassName FameController
 * @Description 名人堂信息管理
 * @Author moses
 * @Date 2021/8/14
 **/
@RestController
@Api(tags = "名人堂信息管理", value = "名人堂信息管理")
@RequestMapping("/fame")
public class FameController {

    @Resource
    private FameService fameService;

    /**
     * 关联学员到名人堂排行榜
     *
     * @param id   学生id
     * @param rank 关联的名次
     * @return
     */
    @ApiOperation("关联学员到名人堂排行榜")
    @PostMapping("/student")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "学员id",type = "int"),
            @ApiImplicitParam(name = "rank",value = "关联名次",type = "double")
    })
    public CommonResult<?> addStudentIdWithRedis(Long id, Double rank) {
        fameService.addStudentIdWithRedis(id, rank);
        return CommonResult.success(null, "关联学员名人堂排行榜成功");
    }

    @ApiOperation("关联导师到名人堂排行榜")
    @PostMapping("/tutor")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "导师id",type = "int"),
            @ApiImplicitParam(name = "rank",value = "关联名次",type = "double")
    })
    public CommonResult<?> addTutorIdWithRedis(Long id, Double rank) {
        fameService.addTutorIdWithRedis(id, rank);
        return CommonResult.success(null, "关联导师名人堂排行榜成功");
    }

    @ApiOperation("取消关联学员到名人堂排行榜")
    @DeleteMapping("/student/{id}")
    @ApiImplicitParam(name = "id",value = "学员id",type = "int")
    public CommonResult<?> delStudentIdWithRedis(@PathVariable("id") Long id) {
        fameService.delStudentByIdWithRedis(id);
        return CommonResult.success(null, "取消关联学员名人堂排行榜成功");
    }

    @ApiOperation("取消关联导师到名人堂排行榜")
    @DeleteMapping("/tutor/{id}")
    @ApiImplicitParam(name = "id",value = " 导师id",type = "int")
    public CommonResult<?> delTutorIdWithRedis(@PathVariable("id") Long id) {
        fameService.delTutorIdWithRedis(id);
        return CommonResult.success(null, "取消关联导师名人堂排行榜成功");
    }

}
